package com.bp.hearthealth.pulse.lnapps.bp_network

import com.google.gson.annotations.JsonAdapter

/**
 * json返回的基本类型
 *
 */
class BaseResp<T> {
    var code = 0
    var msg: String? = null
    val total: String? = null
    val page = 0
    val page_size = 0
    val isSuccess: Boolean
        get() = code == 200  // TODO: 接口请求成功：200  服务器返回正确：0 ？
    @JsonAdapter(BpBaseJsonDataEmptyStringAdapterFactory::class)
    var data: T? = null
    var dataState: DataState? = null
    var error: Throwable? = null
}

enum class DataState {
    STATE_LOADING,//加载中
    STATE_SUCCESS,//成功
    STATE_EMPTY,//数据为null
    STATE_FAILED,//接口请求成功但是服务器返回error
    STATE_ERROR,//请求失败
}